<template>
	<view class="page-wrap" :data-theme="theme" :style="globalColor.style">
		<!-- <HeadCustom title="备考生" :isBlur="true" :isAppBtn="false" :isHome="false"></HeadCustom> -->
		<header-custom title="备考生" :isBlur="true" :isAppBtn="false" :isHome="false" />
		<!--考生-->
		<view class="container fboxWrap Ycenter Xcenter">
			<!-- 消息 -->
			<view class="newsPortal w750 bg-F5FAF7 color-00C15D" @tap="msgClick" v-if="mssageList.length">
				<swiper class="swiper" autoplay circular interval="2000" duration="500" vertical="true">
					<swiper-item v-for="(item, index) in mssageList" :key="index">
						<view class="swiper-item">
							<icon class="bksCIcon bks-c-ziyuan18tongzhi"></icon>
							{{item.notifyTitle}}
						</view>
					</swiper-item>
				</swiper>
				<view class="more">
					<icon class="bksCIcon bks-c-zu font30"></icon>
				</view>
			</view>
			<!-- banner -->
			<view class="banner" v-if="bannerList && bannerList.length">
				<swiper autoplay circular interval="3000" previous-margin="22rpx" next-margin="22rpx"
					indicator-color="rgba(223, 224, 237, 1)" indicator-active-color="rgba(0, 193, 93, 1)" duration="500"
					@change='bannerChangeEnd'>
					<swiper-item class="fboxWrap Ycenter Xcenter" v-for="(item, idx) in bannerList" :key="idx">
						<image class="swiper-item" :class="index == idx ? 'on':''" data-name="bannerList"
							@tap="bannerClick(item.jumpUrl, item.id)" :src="item.url" mode="aspectFill"></image>
					</swiper-item>
				</swiper>
				<view class="dots">
					<view  v-for="(item, idx) in bannerList" :key="idx" class="dot" :class="index == idx ? 'active bg-00C15D':'bg-DFE0ED'"></view>
				</view>
			</view>
			<!--IMG0001-->
			<get-img imgCode="IMG0001" />
			<!-- 资料,成绩 -->
			<get-column code="IMG0002" />
			<!-- 学习 -->
			<view class="w750 fboxCol Ycenter" style="padding-top: 30rpx;">
				<view class="moreTitle w750 fboxRow Ycenter">
					<view class="flex1 fboxRow Ycenter font28 fwb" style="color:#36363A">学习</view>
					<view class="more font22 color-9899A1 fboxRow Ycenter" @tap="pageTo('xuexi')">所有内容<text
							class="bksCIcon bks-c-ziyuan19right font20"></text></view>
				</view>
				<get-column code="IMG0015" />
			</view>
			<!--IMG0003-->
			<get-img className="w690 radius8 mt20" imgCode="IMG0003" />
			<!-- 快捷入口 -->
			<view class="fboxRow quickSchool font22">
				<view class="item fboxCol Ycenter" @tap="pageTo('dxyx')">
					<image src="https://bks-view.obs.cn-north-4.myhuaweicloud.com:443/css/dxyx.jpg" mode="aspectFit">
					</image>
					<text>院校查询</text>
				</view>
				<view class="item fboxCol Ycenter" @tap="pageTo('zycx')">
					<image src="https://bks-view.obs.cn-north-4.myhuaweicloud.com:443/css/zycx.jpg" mode="aspectFit">
					</image>
					<text>专业查询</text>
				</view>
				<view class="item fboxCol Ycenter" @tap="pageTo('xkfx')">
					<image src="https://bks-view.obs.cn-north-4.myhuaweicloud.com:443/css/xkfx.jpg" mode="aspectFit">
					</image>
					<text>新高选科</text>
				</view>
			</view>
			<!--IMG0004-->
			<get-img className="w690 radius8 mt20" imgCode="IMG0004" />
			<!-- 倒计时 -->
			<view class="countDown fboxCol Xcenter" @tap="showShare">
				<image class="w690" style="height:220rpx"
					src="https://bks.obs.cn-north-4.myhuaweicloud.com:443/picture%2FtxUv4Y5kIqTSb3a7d9f6554f25e86522878d40307f50.jpg">
				</image>
				<view class="title font20">距{{shareInfo.year}}年高考仅剩 <text
						class="font26 fwb">{{shareInfo.countdown}}</text> 天</view>
			</view>
			<!-- 热门大学 -->
			<view class="hotSchool w750">
				<view class="moreTitle fboxRow Ycenter">
					<view class="flex1 fboxRow Ycenter font28" style="font-weight:bold;color:#36363A">热门大学</view>
					<view class="more font22 color-9899A1 fboxRow Ycenter" @tap="pageTo('dxyx')">查看所有大学<text
							class="bksCIcon bks-c-ziyuan19right font20"></text></view>
				</view>
				<view class="fboxWrap">
					<view v-for="(item, index) in dataList" :key="index" class="item fboxCol Ycenter" @tap="schoolClick(item.schoolId)">
						<image class="logo" :src="item.logo" mode="aspectFit"></image>
						<view class="tit font26 color-36363A">{{item.schoolName}}</view>
						<view class="con font22 color-9899A1">{{item.popularity}} 热度</view>
					</view>
				</view>
			</view>

			<ad unit-id="adunit-7938fd50b6047e66"></ad>

			<!-- 分享弹窗 -->
			<modal-wrap :detail="shareInfo" :is-show="isShow" @myevent="onColseModal" />

		</view>
		<vip-dialog :showOverlay.sync="showVipPromotion" :isPromotion="true" ident="POP0001" />
		<!-- <pic-dialog ident="TIP0012" /> -->
		
		<BottomTabbar type="bks" active="index" />
	</view>
</template>

<script>
	import headerCustom from '@/pagesBKS/components/header-custom.vue';
	import VipDialog from '@/pagesBKS/components/vip-dialog.vue'
	import ModalWrap from '@/pagesBKS/components/modal-wrap.vue'
	import GetImg from '@/pagesBKS/components/get-img.vue'
	import GetColumn from '@/pagesBKS/components/get-column.vue'
	import BottomTabbar from '@/components/bottom-btn/bottom-tabbar.vue'
	import {
		countdown,
		searchSchoolList
	} from '@/api/bks.examinee'
	import {
		bannerStatistical
	} from '@/api/bks.login'
	import {
		bksFunctionInfo
	} from '@/api/bks.index.js'
	import { getRequest, parseQueryStringt } from '@/static/js/common.js';
	export default {
		components: {
			headerCustom,
			VipDialog,
			GetImg,
			GetColumn,
			BottomTabbar,
			ModalWrap
		},
		data() {
			return {
				theme: 'bks-theme',
				globalColor: getApp().globalData.globalColor,
				bannerList: [],
				quickEntryList: [],
				mssageList: [
					// {
					//   id: 11,
					//   notifyTitle: '高三期末考试，考试答案已更新'
					// }
				],
				shareInfo: {
					// countdown: 147,
					// countdownNotWeekend: null,
					// examDate: "2021年06月07日",
					// motto: "2",
					// pic: "",
					// qrcode: ""
				},
				dataList: [],
				index: 0,
				isShow: false,
				studentInfo: false,
				showVipPromotion: false,
				bgUrl: '',
				Qcode: '',
				// 获取首页顶部轮播 | 获取首页顶部宣传图片 | 获取首页中间两张功能图片 | 获取首页中间宣传图片1 | 获取首页中间宣传图片1
				getInfoList: ['BAN0001', 'IMG0002']
			}
		},
		onLoad(option) {},
		onShow: function() {
			this.request()
		},
		methods: {
			request() {
				// 热门大学
				searchSchoolList({
					page: 1,
					size: 6
				}).then(res => {
					res.data.list.filter(item => {
						if (item.popularity >= 1000) {
							item.popularity = (item.popularity / 10000).toFixed(1) + 'W'
						}
					})
					this.dataList = res.data.list
				})
				// 获取banner 图片
				this.getFunctionInfo()
				// 倒计时
				countdown().then(res => {
					const year = res.data.examDate.slice(0, 4)
					this.shareInfo = {
						...res.data,
						year
					}
				})
				// 消息通知
				// if (wx.$common.getTokenStatus()) {
				//   app.getIsVip((data) => {
				//     notifyList({
				//       "memberId": data.user.memberId,
				//       "notifyType": 1,
				//       "isRead": 0,
				//       "page": 1,
				//       "size": 10
				//     }).then(res => {
				//       this.mssageList=res.data.list
				//     })
				//   })
				// }
			},
			// 后台配置图片
			getFunctionInfo() {
				this.getInfoList.filter(identify => {
					bksFunctionInfo({
						identify
					}).then(res => {
						if (identify == 'BAN0001') {
							this.bannerList= res.data && res.data.list || null
						} else if (identify == 'IMG0002') {
							this.quickEntryList = res.data && res.data.list || null
						}
					})
				})
			},
			// current变化时会触发我们可以在这里面得到当前index标示
			bannerChangeEnd(e) {
				this.index = e.detail.current
			},
			// 轮播图点击事件
			bannerClick(path, id) {
				if (path.indexOf('tips:') != -1) {
					let title = path.split(':')[1]
					uni.showToast({
						title,
						icon: 'none'
					})
				} else {
					const newPath = path.replace('/pages/', '/bks/')
					this.$pageTo(newPath)
					const bw_bks_user = uni.getStorageSync('bw_bks_user') || ''
					const query = parseQueryStringt(path)
					bannerStatistical({
						adId: id,
						linkId: query.id,
						memberId: bw_bks_user.memberId
					})
				}
			},
			// 消息点击跳转消息中心页
			msgClick(e) {
				this.$pageTo('/bks/mine/notify/index')
			},
			// 显示或隐藏分享
			showShare() {
				countdown().then(res => {
					const year = res.data.examDate.slice(0, 4)
					this.shareInfo = {
						...res.data,
						year
					}
					this.isShow = true
				})
			},
			// 关闭分享弹窗
			onColseModal(e) {
				this.isShow = e.detail.isShow || false
			},
			// 跳转页面
			pageTo(name) {
				if (name == 'dxyx') {
					this.$pageTo('/bks/index/school/search/index')
				} else if (name == 'zycx') {
					this.$pageTo('/bks/index/major/search/index')
				} else if (name == 'xkfx') {
					this.$pageTo('/bks/index/analyze/index/index')
				} else if (name == 'xuexi') {
					this.$pageTo('/bks/datum/index/index', 'switchTab')
				}else{
					this.$pageTo(path)
				}
			},
			// 这里是一个自定义方法
			schoolClick(id) {
				this.$pageTo('/bks/index/school/index/index', {
					id
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.page-wrap {
		min-height: calc(100vh);
		background-color: #fff;
	}

	.color-00C15D {
		color: #00C15D
	}

	.container {
		width: 750rpx;
	}

	.swiper-item {
		border-radius: 12rpx;
		overflow: hidden;
	}

	/* 公告,通知 */
	.newsPortal {
		position: relative;
		padding: 0 80rpx 0 30rpx;
		line-height: 80rpx;
		font-size: 24rpx;
		border-radius: 8rpx;
		overflow: hidden;
	}

	.newsPortal swiper {
		height: 80rpx;
	}

	.newsPortal .bksCIcon {
		margin-right: 10rpx;
	}

	.newsPortal .swiper-item {
		height: 80rpx;
		text-overflow: ellipsis;
		white-space: nowrap;
		overflow: hidden;
	}

	.newsPortal .more {
		position: absolute;
		right: 20rpx;
		top: 0;
		height: 80rpx;
	}


	/* banner */
	.banner {
		position: relative;
		width: 750rpx;
		height: 400rpx;
		margin-top: 30rpx;
	}

	.banner swiper {
		position: relative;
		height: 400rpx;
		z-index: 1;
	}

	.banner swiper-item {
		width: 686rpx;
		height: 384rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.banner .swiper-item {
		width: 686rpx;
		height: 260rpx;
		margin-bottom: 50rpx;
		overflow: hidden;
	}

	.banner .on {
		width: 686rpx;
		height: 384rpx;
		margin-bottom: 0;
		overflow: hidden;
	}


	.banner .dots {
		position: absolute;
		left: 0;
		right: 0;
		bottom: 20rpx;
		display: flex;
		justify-content: center;
		z-index: 6;
	}

	.banner .dot {
		margin: 0 8rpx;
		width: 14rpx;
		height: 14rpx;
		border-radius: 8rpx;
		transition: all .6s;
	}

	.banner .dot.active {
		width: 30rpx;
	}

	/* 快捷入口:大学院校,专业查询,选科分析 */

	.quickSchool {
		padding: 18rpx 0 8rpx;
		width: 750rpx;
	}

	.quickSchool .item {
		padding: 30rpx;
		width: 33.33%;
	}

	.quickSchool image {
		width: 88rpx;
		height: 88rpx;
	}

	.quickSchool .item text {
		margin-top: 20rpx;
		color: #333333;
	}

	/* 高考倒计时 */
	.countDown {
		position: relative;
		padding: 20rpx 32rpx 0;
		width: 750rpx;
	}

	.countDown .title {
		position: absolute;
		left: 280rpx;
		bottom: 4rpx;
		width: 300rpx;
		text-align: center;
		height: 52rpx;
		color: #784800;
	}



	.moreTitle {
		padding: 0 30rpx 0;
		height: 44rpx;
	}

	.moreTitle .bksCIcon {
		margin-left: 4rpx;
	}

	/* 热门大学 */
	.hotSchool {
		padding: 30rpx 0
	}

	.hotSchool .item {
		padding: 30rpx 30rpx 10rpx;
		width: 33.33%;
	}

	.hotSchool .logo {
		width: 116rpx;
		height: 116rpx;
		border-radius: 50%;
		overflow: hidden;
	}

	.hotSchool .tit {
		margin-top: 15rpx;
	}

	.hotSchool .con {
		margin-top: 6rpx;
	}
</style>